package com.xuecheng.client.sdk.utils;



import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.HmacAlgorithm;

/**
 * 签名工具
 */
public class SignUtils {
    /**
     * 生成签名
     * @param body
     * @param secretKey
     * @return
     */
    public static String genSign(String body, String secretKey) {

        // 此处密钥如果有非ASCII字符，考虑编码
        byte[] key = secretKey.getBytes();
        HMac mac = new HMac(HmacAlgorithm.HmacSHA256, key);
        return mac.digestHex(body);
    }
}
